<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">添加地址</block>
		</cu-custom>
		<view class="margin-top page-top"></view>
		<view class="cu-form-group ">
			<view class="title">姓名:</view>
			<input placeholder="请输入..." v-model="form.fullName"></input>
		</view>
		<view class="cu-form-group ">
			<view class="title">电话:</view>
			<input placeholder="请输入..." v-model="form.phone"></input>
		</view>
		<view class="cu-form-group ">
			<view class="title">省:</view>
			<input placeholder="请输入..." v-model="form.province"></input>
		</view>
		<view class="cu-form-group ">
			<view class="title">市:</view>
			<input placeholder="请输入..." v-model="form.city"></input>
		</view>
		<view class="cu-form-group ">
			<view class="title">区:</view>
			<input placeholder="请输入..." v-model="form.area"></input>
		</view>
		<view class="cu-form-group ">
			<view class="title">详细地址:</view>
			<input placeholder="请输入..." v-model="form.specificAddress"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">默认地址</view>
			<!-- #ifdef MP-ALIPAY -->
			<switch class='red' @change="SwitchB" :class="form.isDefault?'checked':''"
				:checked="form.isDefault?true:false" color="#e54d42"></switch>
			<!-- #endif -->

			<!-- #ifndef MP-ALIPAY -->
			<switch class='green' @change="SwitchB" :class="form.isDefault?'checked':''"
				:checked="form.isDefault?true:false"></switch>
			<!-- #endif -->
		</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-blue lg" @click="submit()">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					isDefault: false
				},
			}
		},
		methods: {
			SwitchB(e) {
				this.form.isDefault = e.detail.value
			},
			submit() {
				this.crud.post(this.path, "/api/client/all/address", this.form).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title: "添加成功",
							icon: 'none'
						})
						uni.navigateTo({
							url: "/pages/fpage4/address/index",
							success: res => {},
							fail: () => {},
							complete: () => {}
						});
					}
				})
			},
			
		}
	}
</script>

<style>

</style>
